package com.yjs.app.trade.web.controller.sys;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yjs.app.trade.service.service.sys.AdvertisingService;
import com.yjs.app.trade.web.controller.base.BaseController;
import com.yjs.app.trade.web.controller.base.util.Result;

import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "/sys/advertising")
public class AdvertisingController extends BaseController{
	
	@Autowired
	AdvertisingService advertisingService;
	/**
	 * 获取启动页和弹窗广告
	 * @param type
	 * @return
	 */
	@RequestMapping(value="/getStartAd",method=RequestMethod.POST)
	@ResponseBody
	public Object getStartAd(String data){
		JSONObject dpackData = dpackData(data);
		String type = (String) dpackData.get("type");
		int parseInt = Integer.parseInt(type);
		Map<String, Object> startAd = advertisingService.getStartAd(parseInt);
		return Result.csuccess(startAd);
		
	}
	/**
	 * 获取Banner广告
	 * @param type
	 * @return
	 */
	@RequestMapping(value="/getBannerAd",method=RequestMethod.POST)
	@ResponseBody
	public Object getBannerAd(String data){
		JSONObject dpackData = dpackData(data);
		String type = (String) dpackData.get("type");
		int parseInt = Integer.parseInt(type);
		List<Map<String, Object>> startAd = advertisingService.getBannerAd(parseInt);
		return Result.csuccess(startAd);
	}
}
